package model;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class MyOrder {
    
    public Integer getOrderId() throws Exception{
        String sql="select nvl(max(orderid),0)+1 as myId from FOODORDER";
        List<Map> result=Dbuit.query(sql);
        return Integer.parseInt((result.get(0).get("MYID").toString()));
        
    }
    
    public Integer saveOrder(String deskId,int state) throws Exception{
        Integer orderId=getOrderId();
        String sql="insert into FOODORDER values('"+orderId+"','"+deskId+"',sysdate,'"+state+"')";
        Dbuit.execute(sql);
        return orderId;
    }
    /**
     * 10111
     *   1  XXX 2
     *   2  YYY 1
     *  
     * 
     * @param orderId
     * @param detail
     * @throws Exception 
     */
    public void saveOrderDetail(Integer orderId,Integer foodId,Integer count) throws Exception{
            String sql="insert into FOODORDERDETAIL values((select nvl(max(detailid),0)+1 as myId from foodorderdetail),"
                    + "'"+orderId+"','"+foodId+"','"+count+"')";
            Dbuit.execute(sql);
    }
    
    
   
   
   
   
}
